package org.jeecg.modules.htxincailiao.account.constant;

public interface HTAccountConstant {

    //lock_time
    //failed_attempt
    //account_non_locked
    //totalAttempts
    //登录最大尝试次数(锁定阈值)
    static final int SIGN_IN_MAX_FAILED_ATTEMPTS = 5;

    //尝试登录失败持续时间 /密码连续输入N次失败的持续时间
//    static final int SIGN_IN_FAILED_ATTEMPTS_TIME_DURATION = 10 * 60 * 1000 ;
    //Limit on Log-In Attempts

    //登录失败 锁定时长 分钟 分 秒 毫秒
    static final int SIGN_IN_FAILED_LOCK_TIME_DURATION  =  10 * 60;

    static final String SIGN_IN_FAILED_LOCK_KEY_PREFIX  = "SignInFailedLockKeyPrefix";

    static final String SIGN_IN_FAILED_ATTEMPT_COUNT_KEY_PREFIX  = "SignInFailedAttemptCountKeyPrefix";

}


//        fail_count = get_from_redis(fail_username)
//        locked = get_from_redis(lock_username)
//
//        if locked:
//        return error('拒绝登录')
//        if fail_count >= 3:
//        if captcha is None:
//        return error('需要验证码')
//        check_captcha(captcha)
//        success = do_login(username, password)
//        if not success:
//        set_redis(fail_username, fail_count + 1)
//        if fail_count + 1 >= 10:
//     # 失败超过10次，设置锁定标记
//        set_redis(lock_username, true, 300s)

//        String limitKey =  mobile + "_login_error_times";
//        String limitTimes = RedisUtils.get(limitKey);
//        Integer times = 1;
//        if (limitTimes != null) {
//            if (new Integer(limitTimes).intValue() >= 6) {
//                result.setSuccess(false);
//                result.setMsg("当前账号今日登录失败次数超过6次，为保证您的账号安全，系统已锁定当前账号，您可明天再登录或立即重置密码后使用新密码登录！");
//                return result;
//            }
//            times = new Integer(limitTimes) + 1;
//
//            if (kaptcha == null && times > 3) {
//                result.setPage(1);//该字段如果为1，表示前端需要用户输入谷歌图形验证码接口
//                result.setSuccess(false);
//                result.setMsg("您没有输入验证码");
//                return result;
//            }
//        }
